package com.itheima.mapper;

import com.itheima.pojo.CheckItem;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CheckItemMapper {


    /**
     * 添加检查项
     * @param checkItem
     */
    @Insert("INSERT into t_checkitem (id, code, name, sex, age, price, type, remark, attention) " +
            "values (#{id}, #{code}, #{name}, #{sex}, #{age}, #{price}, #{type}, #{remark}, #{attention})")
    void addChekck(CheckItem checkItem);

    /**
     * 根据id删除检查项
     * @param id
     */
    @Delete("delete from t_checkitem where id = #{id}")
    void deleteChceck(int id);

    /**
     * 更新检查项
     * @param checkItem
     */
    @Insert("update t_checkitem set code = #{code}, name = #{name}, sex = #{sex}, age = #{age}, price = #{price}, type = #{type}, remark = #{remark}, attention = #{attention} where id = #{id}")
    void update(CheckItem checkItem);

    /**
     * 分页查询
     * @param currentPage
     * @param pageSize
     * @param queryString
     * @return
     */
    List<CheckItem> pageList(Integer currentPage, Integer pageSize, String queryString);

    /**
     * 查询所有检查项
     * @return
     */
    @Select("select * from t_checkitem")
    List<CheckItem> findAll();

    /**
     * 根据id查询检查项
     * @param id
     * @return
     */
    @Select("select * from t_checkitem where id = #{id}")
    CheckItem findById(int id);

    /**
     * 根据检查组id查询检查项id
     * @param checkgroupId
     * @return
     */
    @Select("select checkitem_id from t_checkgroup_checkitem where checkgroup_id = #{checkgroupId}")
    List<Integer> findCheckItemIdsByCheckGroupId(int checkgroupId);
}
